package com.hz.controller;

import com.hz.dao.UserRechargeDao;
import com.hz.pojo.UserRecharge;
import com.hz.service.impl.UserRechargeServiceImpl;
import com.hz.utils.MassageJsons;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/UserRecharge")
public class UserRechargeController {
    @Resource
    UserRechargeServiceImpl userRechargeService;
    @Resource
    UserRechargeDao userRechargeDao;

    /**
     * 获取所有充值信息,分页
     */
    @RequestMapping("/getAllUserRecharge")
    public MassageJsons getAllUserRecharge(Integer pages, Integer pageSize,String name){

        List<UserRecharge> list = null;
        int i = 0;
        try {
            i = userRechargeDao.getAllUserRechargeCount();
             /*start:就是当前页的起始索引,pageSize就是每页的条数
            pages:就是当前页
            */
            int start=(pages-1) * pageSize;
            list=userRechargeService.getAllUserRecharge(start,pageSize,name);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new MassageJsons("0","请求成功",list,i);
    }
}
